package com.allwees.bs.c.module.user.dao;

import com.allwees.bs.c.module.user.entity.UserSignInLogEntity;
import com.allwees.core.dao.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author Daniel
 * @Version 1.0.0
 * @Description
 * @CreateTime 2020/9/12 13:59
 */
public interface UserSignInLogDao extends BaseDao<UserSignInLogEntity> {

    @Select({"SELECT * FROM usr_sign_in_log s WHERE s.user_uuid = #{userUuid} ORDER BY s.id desc limit 1"})
    UserSignInLogEntity getLast(@Param("userUuid") String userUuid);

    @Select({"SELECT * FROM usr_sign_in_log s WHERE s.user_uuid = #{userUuid} ORDER BY s.id DESC limit #{limit}"})
    List<UserSignInLogEntity> queryByLimit(@Param("userUuid") String userUuid, @Param("limit") int limit);

    @Select({"SELECT count(*) FROM usr_sign_in_log s WHERE s.user_uuid = #{userUuid} AND s.status = 0 AND s.cycle_type = #{cycleType}"})
    int countNormalEndCycle(@Param("userUuid") String userUuid, @Param("cycleType") String cycleType);

}
